package top.yonyong.myprometheus.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

/**
 * @author admin
 */
@Configuration
public class SwaggerConfig {

    @Bean
    public Docket petApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                //指定提供接口所在的基包
                .apis(RequestHandlerSelectors.basePackage("top.yonyong.myprometheus.rest"))
                .build();
    }

    /**
     * 该套 API 说明，包含作者、简介、版本、host、服务URL
     * @return
     */
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("prometheus")
                .contact(new Contact("yonyong","yonyong","yangde@myai.tech"))
                .version("1.0.0.SNAPSHOT")
                .termsOfServiceUrl("localhost:8080/metrics/swagger-ui.html")
                .description("prometheus demo")
                .build();
    }

}